<!DOCTYPE html>
<!-- saved from url=(0047)https://www.cnblogs.com/echo3621/p/5551712.html -->
<html lang="zh-cn"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="referrer" content="origin">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <title>JS原型+原型链+设计模式 - 张处羊 - 博客园</title>
    <meta property="og:description" content="JavaScript是一种基于对象的语言，JavaScript中的所有对象，都具有prototype属性。prototype属性返回对象的所有属性和方法，所有 JavaScript ">
    <link type="text/css" rel="stylesheet" href="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/blog-common.css">
<link id="MainCss" type="text/css" rel="stylesheet" href="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/bundle-LessIsMoreRight.css">
<link id="mobile-style" media="only screen and (max-width: 767px)" type="text/css" rel="stylesheet" href="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/bundle-LessIsMoreRight-mobile.css">
    <link title="RSS" type="application/rss+xml" rel="alternate" href="https://www.cnblogs.com/echo3621/rss">
    <link title="RSD" type="application/rsd+xml" rel="EditURI" href="https://www.cnblogs.com/echo3621/rsd.xml">
<link type="application/wlwmanifest+xml" rel="wlwmanifest" href="https://www.cnblogs.com/echo3621/wlwmanifest.xml">
    <script src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/amp4ads-host-v0.js.下载"></script><script src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/pubads_impl_rendering_2019061301.js.下载"></script><script async="" src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/analytics.js.下载"></script><script src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/jquery-2.2.0.min.js.下载"></script>
    <script>var currentBlogId=257502;var currentBlogApp='echo3621',cb_enable_mathjax=false;var isLogined=false;</script>
    <script src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/blog-common.js.下载" type="text/javascript"></script>
<link rel="preload" href="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/f.txt" as="script"><script type="text/javascript" src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/f.txt"></script><script src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/pubads_impl_2019061301.js.下载" async=""></script><link rel="prefetch" href="https://tpc.googlesyndication.com/safeframe/1-0-33/html/container.html"></head>
<body>
<a name="top"></a>


<div id="home">
<div id="header">
	<div id="blogTitle">
		
<!--done-->
<div class="title"><a id="Header1_HeaderTitle" class="headermaintitle" href="https://www.cnblogs.com/echo3621/">张处羊</a></div>
<div class="subtitle"></div>



		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<ul id="navList">
<li id="nav_sitehome"><a id="blog_nav_sitehome" class="menu" href="https://www.cnblogs.com/">博客园</a></li>
<li id="nav_myhome"><a id="blog_nav_myhome" class="menu" href="https://www.cnblogs.com/echo3621/">首页</a></li>
<li id="nav_newpost"><a id="blog_nav_newpost" class="menu" rel="nofollow" href="https://i.cnblogs.com/EditPosts.aspx?opt=1">新随笔</a></li>
<li id="nav_contact"><a id="blog_nav_contact" class="menu" rel="nofollow" href="https://msg.cnblogs.com/send/%E5%BC%A0%E5%A4%84%E7%BE%8A">联系</a></li>
<li id="nav_rss"><a id="blog_nav_rss" class="menu" href="https://www.cnblogs.com/echo3621/rss">订阅</a>
<!--<a id="blog_nav_rss_image" class="aHeaderXML" href="https://www.cnblogs.com/echo3621/rss"><img src="//www.cnblogs.com/images/xml.gif" alt="订阅" /></a>--></li>
<li id="nav_admin"><a id="blog_nav_admin" class="menu" rel="nofollow" href="https://i.cnblogs.com/">管理</a></li>
</ul>

		<div class="blogStats">
			
			<div id="blog_stats">
<!--done-->
随笔-2&nbsp;
文章-0&nbsp;
评论-1&nbsp;
</div>
			
		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->
<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		
        <div id="post_detail">
<!--done-->
<div id="topics">
	<div class="post">
		<h1 class="postTitle">
			<a id="cb_post_title_url" class="postTitle2" href="https://www.cnblogs.com/echo3621/p/5551712.html">JS原型+原型链+设计模式</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			<div id="cnblogs_post_body" class="blogpost-body"><p>JavaScript<span style="font-family: 宋体;">是一种基于对象的语言，</span><span style="font-family: &#39;Courier New&#39;;">JavaScript</span><span style="font-family: 宋体;">中的所有对象，都具有</span><span style="font-family: &#39;Courier New&#39;;">prototype</span><span style="font-family: 宋体;">属性。</span><span style="font-family: &#39;Courier New&#39;;">prototype</span><span style="font-family: 宋体;">属性返回对象的所有属性和方法，所有&nbsp;</span><span style="font-family: &#39;Courier New&#39;;">JavaScript&nbsp;</span><span style="font-family: 宋体;">内部对象都有只读的&nbsp;</span><span style="font-family: &#39;Courier New&#39;;">prototype&nbsp;</span><span style="font-family: 宋体;">属性，可以向其原型中动态添加属性和方法，但该对象不能被赋予不同的原型。但是自定义的对象可以被赋给新的原型。</span></p>
<p>对象分为函数对象和普通对象，区分：凡是通过 new Function() 创建的对象都是函数对象，其他的都是普通对象。（Object ，Function 是JS自带的函数对象）</p>
<p>1.原型对象：<span style="line-height: 1.5;">prototype</span></p>
<p>&nbsp;在JS 中，函数对象其中一个属性：原型对象 prototype。普通对象是没有prototype属性,但有__proto__属性。</p>
<p>原型的作用就是给这个类的每一个对象都添加一个统一的方法,在原型中定义的方法和属性都是被所以实例对象所共享。</p>
<p>&nbsp;　　例：</p>
<p>　　　　 &nbsp;var person = function(name){<br>&nbsp;&nbsp;　　　　　　&nbsp;this.name = name<br>&nbsp;　　　　&nbsp;};<br>&nbsp;　　　　&nbsp;person.prototype.getName = function(){//通过person.prototype设置函数对象属性<br>&nbsp;&nbsp;&nbsp;&nbsp;　　　　　　&nbsp;return this.name;&nbsp;<br>&nbsp;　　　　&nbsp;}<br>&nbsp;　　　　&nbsp;var zxj= new person(‘zhangxiaojie’);<br>&nbsp;&nbsp;　　　　zxj.getName(); //zhangxiaojie &nbsp;&nbsp;　　　　//zxj继承上属性</p>
<p>2.原型链</p>
<p>&nbsp;__proto__：js创建对象的内置属性，用于指向创建它的函数对象的原型对象prototype。（是JS内部使用寻找原型链的属性。当实例化一个对象时候，内部会新建一个__proto__属性并把prototype赋值给它）</p>
<p>　　　　下图为原型链运行图解，当我们实例一个对象之后，调用它的内部方法，他的运行顺序是先找自身有没有该方法，如果没有就会通过__proto__属性想上层寻找，一直寻找到Object对象中，如果还没有才会报错null</p>
<p>　　　　　　　　p._proto_-----&gt;Persion._proto_----&gt;object._proto_-----&gt;null</p>
<p>&nbsp;</p>
<p>3.设计模式</p>
<p>（1）工厂模式：在函数内创建一个对象，给对象赋予属性及方法再将对象返回。</p>
<p>&nbsp;&nbsp;&nbsp;　　 function Parent(){ &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　var&nbsp; Child = new Object(); &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　 Child.name="ZXJ"; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　Child.age="24";</p>
<p>　　　　　　Child.sex=function(){ &nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　　　　　return "女"; &nbsp;<br>&nbsp;&nbsp;&nbsp;　　　　　&nbsp;}; &nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　return Child; &nbsp;<br>&nbsp;&nbsp;&nbsp; 　　}; &nbsp;<br>&nbsp; &nbsp; &nbsp; 调用：<br>&nbsp;&nbsp;&nbsp; 　　var&nbsp; x =Parent(); &nbsp;</p>
<p><em id="__mceDel">&nbsp; 　　&nbsp;&nbsp;alert(x.name); &nbsp; &nbsp; &nbsp;//ZXJ<br>&nbsp;&nbsp;&nbsp;　　 alert(x.sex()); &nbsp; &nbsp; &nbsp; //女</em></p>
<p>（2）构造函数模式:无需再函数内部重建创建对象，而使用this指代</p>
<p>　　　　<em id="__mceDel" style="line-height: 1.5;">&nbsp;function Parent(){ &nbsp;</em></p>
<p><em id="__mceDel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　 var&nbsp; Child = new Object(); &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　&nbsp; this.name="ZXJ"; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　&nbsp; this.age=24"; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　&nbsp; this.lev=lev;&nbsp;&nbsp;</em></p>
<p>　　　　　　Child.sex=function(){ &nbsp;</p>
<p><em id="__mceDel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　　　　　return "女"; &nbsp;<br>&nbsp;&nbsp;&nbsp;　　　　 &nbsp; }; &nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　 &nbsp;return Child; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;　　 &nbsp;}; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; 调用：<br>&nbsp;&nbsp;&nbsp;&nbsp;　　 &nbsp;var&nbsp; x = new&nbsp;Parent(); &nbsp;<br>&nbsp;&nbsp;　　 &nbsp; &nbsp;alert(x.name); &nbsp; &nbsp; &nbsp;//ZXJ<br>&nbsp;&nbsp;&nbsp;　　 &nbsp; alert(x.sex()); &nbsp; &nbsp; &nbsp; //女</em></p>
<p>　　(3)原型模式：函数中不对属性进行定义，利用prototype属性对属性进行定义，可以让所有对象实例共享它所包含的属性及方法。</p>
<p>　　　　function Parent(){&nbsp;&nbsp; }; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　　　 Parent.prototype.name="<em id="__mceDel">ZXJ</em>"; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　　　 Parent.prototype.age="24"; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　　　 Parent.prototype.sex=function(){</p>
<p>　　　　　　　　var s="女";</p>
<p>　　　　　　　　alert(s);</p>
<p>　　　　　　}; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p>　　　　&nbsp;<em id="__mceDel">调用：</em><br>&nbsp;&nbsp;&nbsp; 　　　　var&nbsp; x =new&nbsp; Parent(); &nbsp;<br>&nbsp;&nbsp;&nbsp; 　　　　<em id="__mceDel">alert(x.name); &nbsp; &nbsp; &nbsp;//ZXJ<br>&nbsp;&nbsp;&nbsp;　　 &nbsp; &nbsp; &nbsp;alert(x.sex()); &nbsp; &nbsp; &nbsp; //女</em></p>
<p>&nbsp;</p>
<p>　　(4)混合模式：原型模式+构造函数模式。这种模式中，<span style="font-family: 宋体; font-size: 15px;">构造函数模式用于定义实例属性，而原型模式用于定义方法和共享属性。</span></p>
<p><span style="font-family: 宋体; font-size: 15px;">　　　　&nbsp;function Parent(){ &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　　　 this.name="ZXJ"; &nbsp;<br>&nbsp;&nbsp;&nbsp; &nbsp;　　　　 this.age=24;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp; 　　};<br>&nbsp;&nbsp;&nbsp;　　 Parent.prototype.sayname=function(){&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　 return this.name; &nbsp;<br>&nbsp;&nbsp;&nbsp;　　 };<br>&nbsp; &nbsp; &nbsp; 调用：<br>&nbsp;&nbsp;&nbsp;　　 var&nbsp; x =new&nbsp; Parent();&nbsp;<br>&nbsp;&nbsp;&nbsp;　　 alert(x.sayname()); &nbsp; //ZXJ　　</span></p>
<p>&nbsp;</p>
<p><span style="font-family: 宋体; font-size: 15px;">　　(5)动态原型模式:</span><span style="font-family: 宋体; font-size: 15px;">将所有信息封装在了构造函数中，而通过构造函数中初始化原型，这个可以通过判断该方法是否有效而选择是否需要初始化原型。</span></p>
<p>&nbsp;</p>
<p><span style="font-family: 宋体; font-size: 15px;">　　　　function Parent(){ &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　this.name="ZXJ"; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;　　&nbsp;&nbsp;this.age=24;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; 　　if(typeof Parent._sayname=="undefined"){ &nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　Parent.prototype.sayname=function(){&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.name; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　　 } &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Parent._sayname=true; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; };&nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp;调用：&nbsp;<br>&nbsp;&nbsp;&nbsp; var&nbsp; x =new&nbsp; Parent();&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp; alert(x.sayname()); &nbsp;</span></p>
<p>&nbsp;</p></div><div id="MySignature"></div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="BlogPostCategory"></div>
<div id="EntryTag">标签: <a href="https://www.cnblogs.com/echo3621/tag/JS%E5%8E%9F%E5%9E%8B/">JS原型</a>, <a href="https://www.cnblogs.com/echo3621/tag/JS%E5%8E%9F%E5%9E%8B%E9%93%BE/">JS原型链</a>, <a href="https://www.cnblogs.com/echo3621/tag/JS%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">JS设计模式</a></div>
<div id="blog_post_info"><div id="green_channel">
        <a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(5551712,cb_blogId,1);green_channel_success(this,&#39;谢谢推荐！&#39;);">好文要顶</a>
            <a id="green_channel_follow" onclick="follow(&#39;e08f76ab-8496-e511-9fc1-ac853d9f53cc&#39;);" href="javascript:void(0);">关注我</a>
    <a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a>
    <a id="green_channel_weibo" href="javascript:void(0);" title="分享至新浪微博" onclick="ShareToTsina()"><img src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/icon_weibo_24.png" alt=""></a>
    <a id="green_channel_wechat" href="javascript:void(0);" title="分享至微信" onclick="shareOnWechat()"><img src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/wechat.png" alt=""></a>
</div>
<div id="author_profile">
    <div id="author_profile_info" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/echo3621/" target="_blank"><img src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/sample_face.gif" class="author_avatar" alt=""></a>
        <div id="author_profile_detail" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/echo3621/">张处羊</a><br>
            <a href="https://home.cnblogs.com/u/echo3621/followees">关注 - 0</a><br>
            <a href="https://home.cnblogs.com/u/echo3621/followers">粉丝 - 1</a>
        </div>
    </div>
    <div class="clear"></div>
    <div id="author_profile_honor"></div>
    <div id="author_profile_follow">
                <a href="javascript:void(0);" onclick="follow(&#39;e08f76ab-8496-e511-9fc1-ac853d9f53cc&#39;);return false;">+加关注</a>
    </div>
</div>
<div id="div_digg">
    <div class="diggit" onclick="votePost(5551712,&#39;Digg&#39;)">
        <span class="diggnum" id="digg_count">0</span>
    </div>
    <div class="buryit" onclick="votePost(5551712,&#39;Bury&#39;)">
        <span class="burynum" id="bury_count">0</span>
    </div>
    <div class="clear"></div>
    <div class="diggword" id="digg_tips">
    </div>
</div>
<script type="text/javascript">
    currentDiggType = 0;
</script></div>
<div class="clear"></div>
<div id="post_next_prev"><a href="https://www.cnblogs.com/echo3621/p/5579002.html" class="p_n_p_prefix">» </a> 下一篇：<a href="https://www.cnblogs.com/echo3621/p/5579002.html" title="发布于2016-06-12 22:24">算法——冒泡排序</a><br></div>
</div>


		</div>
		<div class="postDesc">posted @ <span id="post-date">2016-06-02 21:57</span> <a href="https://www.cnblogs.com/echo3621/">张处羊</a> 阅读(<span id="post_view_count">2337</span>) 评论(<span id="post_comment_count">1</span>)  <a href="https://i.cnblogs.com/EditPosts.aspx?postid=5551712" rel="nofollow">编辑</a> <a href="https://www.cnblogs.com/echo3621/p/5551712.html#" onclick="AddToWz(5551712);return false;">收藏</a></div>
	</div>
	<script type="text/javascript">var allowComments=true,cb_blogId=257502,cb_entryId=5551712,cb_blogApp=currentBlogApp,cb_blogUserGuid='e08f76ab-8496-e511-9fc1-ac853d9f53cc',cb_entryCreatedDate='2016/6/2 21:57:00';loadViewCount(cb_entryId);var cb_postType=1;var isMarkdown=false;</script>
	
</div><!--end: topics 文章、评论容器-->
</div><a name="!comments"></a><div id="blog-comments-placeholder"><div id="comments_pager_top"></div>
<!--done-->
<div class="feedback_area_title">评论列表</div>
<div class="feedbackNoItems"></div>
	

		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"></span>
				</div>
				<a href="https://www.cnblogs.com/echo3621/p/5551712.html#4007794" class="layer">#1楼</a><a name="4007794" id="comment_anchor_4007794"></a><span id="comment-maxId" style="display:none;">4007794</span><span id="comment-maxDate" style="display:none;">2018/6/28 15:39:32</span>  <span class="comment_date">2018-06-28 15:39</span> <a id="a_comment_author_4007794" href="http://home.cnblogs.com/u/760582/" target="_blank">风雨造就春华秋实</a> <a href="http://msg.cnblogs.com/send/%E9%A3%8E%E9%9B%A8%E9%80%A0%E5%B0%B1%E6%98%A5%E5%8D%8E%E7%A7%8B%E5%AE%9E" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_4007794" class="blog_comment_body">（2）构造函数模式:无需再函数内部重建创建对象，而使用this指代<br><br>　　　　 function Parent(){  <br><br>           　　 var  Child = new Object();  <br>          　　  this.name="ZXJ";  <br>          　　  this.age=24";  <br>          　　  this.lev=lev;  <br><br>　　　　　　Child.sex=function(){  <br><br>       　　　　　　return "女";  <br>   　　　　   };   <br>         　　  return Child;  <br>    　　  };  <br>        调用：<br>    　　  var  x = new Parent();  <br>  　　    alert(x.name);      //ZXJ<br>   　　   alert(x.sex());       //女<br><br><br>这代码是不是有问题，你还能渠道name，我是不是逗我们开心</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4007794,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4007794,&#39;Bury&#39;,this)">反对(0)</a></div>
			</div>
		</div>
	<div id="comments_pager_bottom"></div></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
<div id="comment_form" class="commentform">
<a name="commentform"></a>
<div id="divCommentShow"></div>
<div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" onclick="return RefreshCommentList();" id="lnk_RefreshComments" runat="server" clientidmode="Static">刷新评论</a><a href="https://www.cnblogs.com/echo3621/p/5551712.html#" onclick="return RefreshPage();">刷新页面</a><a href="https://www.cnblogs.com/echo3621/p/5551712.html#top">返回顶部</a></div>
<div id="comment_form_container"><div class="login_tips">注册用户登录后才能发表评论，请 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return login(&#39;commentform&#39;);">登录</a> 或 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return register();">注册</a>，<a href="http://www.cnblogs.com/">访问</a>网站首页。</div></div>
<div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
<div id="ad_t2"><a href="http://www.ucancode.com/index.htm" target="_blank" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;T2-工控&#39;)">【推荐】超50万C++/C#源码: 大型实时仿真组态图形源码</a><br><a href="https://www.grapecity.com.cn/developer/spreadjs?utm_source=cnblogs&amp;utm_medium=blogpage&amp;utm_term=bottom&amp;utm_content=SpreadJS&amp;utm_campaign=community" target="_blank" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;T2-SpreadJS&#39;)">【前端】SpreadJS表格控件，可嵌入系统开发的在线Excel</a><br><a href="https://ke.qq.com/adActivity.html?name=xiangxueketang2" target="_blank" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;T2-享学&#39;)">【培训】阿里P8面试官：什么样的人能进阿里</a><br><a href="https://q.cnblogs.com/" target="_blank" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;T2-博问&#39;)">【推荐】程序员问答平台，解决您开发中遇到的技术难题</a><br></div>
<div id="opt_under_post"></div>
<script async="async" src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/gpt.js.下载"></script>
<script>
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];
</script>
<script>
  googletag.cmd.push(function() {
        googletag.defineSlot('/1090369/C1', [300, 250], 'div-gpt-ad-1546353474406-0').addService(googletag.pubads());
        googletag.defineSlot('/1090369/C2', [468, 60], 'div-gpt-ad-1539008685004-0').addService(googletag.pubads());
        googletag.pubads().enableSingleRequest();
        googletag.enableServices();
  });
</script>
<div id="cnblogs_c1" class="c_ad_block">
    <div id="div-gpt-ad-1546353474406-0" style="height:250px; width:300px;" data-google-query-id="CLX05Nb-8eICFQV5vQod3oIIMg"><div id="google_ads_iframe_/1090369/C1_0__container__" style="border: 0pt none;"><iframe id="google_ads_iframe_/1090369/C1_0" title="3rd party ad content" name="google_ads_iframe_/1090369/C1_0" width="300" height="250" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" style="border: 0px; vertical-align: bottom;" data-google-container-id="1" data-load-complete="true" src="./JS原型+原型链+设计模式 - 张处羊 - 博客园_files/saved_resource.html"></iframe></div></div>
</div>
<div id="under_post_news"><div class="recomm-block"><b>相关博文：</b><br>·  <a href="https://www.cnblogs.com/suhaihong/p/6708628.html" target="_blank" onclick="clickRecomItmem(6708628)">js原型与原型链</a><br>·  <a href="https://www.cnblogs.com/zhuyuannet/p/5806431.html" target="_blank" onclick="clickRecomItmem(5806431)">JS原型链</a><br>·  <a href="https://www.cnblogs.com/chenlogin/p/5120667.html" target="_blank" onclick="clickRecomItmem(5120667)">javascript原型链</a><br>·  <a href="https://www.cnblogs.com/hello-web/p/6852739.html" target="_blank" onclick="clickRecomItmem(6852739)">JS原型和继承</a><br>·  <a href="https://www.cnblogs.com/yinqiong/p/5887399.html" target="_blank" onclick="clickRecomItmem(5887399)">js-对象创建-继承-原型链等概念</a><br></div></div>
<div id="cnblogs_c2" class="c_ad_block">
    <div id="div-gpt-ad-1539008685004-0" style="height:60px; width:468px;" data-google-query-id="CLb05Nb-8eICFQV5vQod3oIIMg"><div id="google_ads_iframe_/1090369/C2_0__container__" style="border: 0pt none; width: 468px; height: 60px;"></div></div>
</div>
<div id="under_post_kb"><div class="itnews c_ad_block"><b>最新新闻</b>：<br> ·  <a href="https://news.cnblogs.com/n/627000/" target="_blank">抵达土星仅用两年，这艘核聚变飞船值得期待！</a><br> ·  <a href="https://news.cnblogs.com/n/626999/" target="_blank">郭明錤：苹果明年发两款5G手机 高通还是主要供应商</a><br> ·  <a href="https://news.cnblogs.com/n/626998/" target="_blank">赛・飞天：中国“马斯克”们抢跑商业航天</a><br> ·  <a href="https://news.cnblogs.com/n/626997/" target="_blank">京东数科618一小时战报：白条交易额24秒破亿</a><br> ·  <a href="https://news.cnblogs.com/n/626996/" target="_blank">谷歌CEO：YouTube体量太大 无法完全杜绝有害内容</a><br>» <a href="http://news.cnblogs.com/" title="IT新闻" target="_blank">更多新闻...</a></div></div>
<div id="HistoryToday" class="c_ad_block"></div>
<script type="text/javascript">
 if(enablePostBottom()) {
    codeHighlight();
    fixPostBody();
    setTimeout(function () { incrementViewCount(cb_entryId); }, 50);
    deliverT2();
    deliverC1();
    deliverC2();    
    loadNewsAndKb();
    loadBlogSignature();
    LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
    GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType);
    loadOptUnderPost();
    GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);  
}
</script>
</div>

    
	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->

	<div id="sideBar">
		<div id="sideBarMain">
			
<!--done-->
<div class="newsItem">
<h3 class="catListTitle">公告</h3>
	<div id="blog-news"><div id="profile_block">昵称：<a href="https://home.cnblogs.com/u/echo3621/">张处羊</a><br>园龄：<a href="https://home.cnblogs.com/u/echo3621/" title="入园时间：2015-11-29">3年6个月</a><br>粉丝：<a href="https://home.cnblogs.com/u/echo3621/followers/">1</a><br>关注：<a href="https://home.cnblogs.com/u/echo3621/followees/">0</a><div id="p_b_follow"><a href="javascript:void(0);" onclick="follow(&#39;e08f76ab-8496-e511-9fc1-ac853d9f53cc&#39;)">+加关注</a></div><script>getFollowStatus('e08f76ab-8496-e511-9fc1-ac853d9f53cc')</script></div></div><script type="text/javascript">loadBlogNews();</script>
</div>

			<div id="calendar"><div id="blog-calendar" style=""><table id="blogCalendar" class="Cal" cellspacing="0" cellpadding="0" title="Calendar">
	<tbody><tr><td colspan="7"><table class="CalTitle" cellspacing="0">
		<tbody><tr><td class="CalNextPrev"><a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2019/05/01&#39;);return false;">&lt;</a></td><td align="center">2019年6月</td><td class="CalNextPrev" align="right"><a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2019/07/01&#39;);return false;">&gt;</a></td></tr>
	</tbody></table></td></tr><tr><th class="CalDayHeader" align="center" abbr="日" scope="col">日</th><th class="CalDayHeader" align="center" abbr="一" scope="col">一</th><th class="CalDayHeader" align="center" abbr="二" scope="col">二</th><th class="CalDayHeader" align="center" abbr="三" scope="col">三</th><th class="CalDayHeader" align="center" abbr="四" scope="col">四</th><th class="CalDayHeader" align="center" abbr="五" scope="col">五</th><th class="CalDayHeader" align="center" abbr="六" scope="col">六</th></tr><tr><td class="CalOtherMonthDay" align="center">26</td><td class="CalOtherMonthDay" align="center">27</td><td class="CalOtherMonthDay" align="center">28</td><td class="CalOtherMonthDay" align="center">29</td><td class="CalOtherMonthDay" align="center">30</td><td class="CalOtherMonthDay" align="center">31</td><td class="CalWeekendDay" align="center">1</td></tr><tr><td class="CalWeekendDay" align="center">2</td><td align="center">3</td><td align="center">4</td><td align="center">5</td><td align="center">6</td><td align="center">7</td><td class="CalWeekendDay" align="center">8</td></tr><tr><td class="CalWeekendDay" align="center">9</td><td align="center">10</td><td align="center">11</td><td align="center">12</td><td align="center">13</td><td align="center">14</td><td class="CalWeekendDay" align="center">15</td></tr><tr><td class="CalWeekendDay" align="center">16</td><td align="center">17</td><td class="CalTodayDay" align="center">18</td><td align="center">19</td><td align="center">20</td><td align="center">21</td><td class="CalWeekendDay" align="center">22</td></tr><tr><td class="CalWeekendDay" align="center">23</td><td align="center">24</td><td align="center">25</td><td align="center">26</td><td align="center">27</td><td align="center">28</td><td class="CalWeekendDay" align="center">29</td></tr><tr><td class="CalWeekendDay" align="center">30</td><td class="CalOtherMonthDay" align="center">1</td><td class="CalOtherMonthDay" align="center">2</td><td class="CalOtherMonthDay" align="center">3</td><td class="CalOtherMonthDay" align="center">4</td><td class="CalOtherMonthDay" align="center">5</td><td class="CalOtherMonthDay" align="center">6</td></tr>
</tbody></table></div><script type="text/javascript">loadBlogDefaultCalendar();</script></div>
			
			<div id="leftcontentcontainer">
				<div id="blog-sidecolumn"><div id="sidebar_search" class="sidebar-block">
<div id="sidebar_search" class="mySearch">
<h3 class="catListTitle">搜索</h3>
<div id="sidebar_search_box">
<div id="widget_my_zzk" class="div_my_zzk"><input type="text" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk">&nbsp;<input onclick="zzk_go()" type="button" value="找找看" id="btnZzk" class="btn_my_zzk"></div>
<div id="widget_my_google" class="div_my_zzk"><input type="text" name="google_q" id="google_q" onkeydown="return google_go_enter(event)" class="input_my_zzk">&nbsp;<input onclick="google_go()" type="button" value="谷歌搜索" class="btn_my_zzk"></div>
</div>
</div>

</div><div id="sidebar_shortcut" class="sidebar-block">
<div class="catListLink">
<h3 class="catListTitle">常用链接</h3>
<ul>
<li><a href="https://www.cnblogs.com/echo3621/p/" title="我的博客的随笔列表">我的随笔</a></li><li><a href="https://www.cnblogs.com/echo3621/MyComments.html" title="我发表过的评论列表">我的评论</a></li><li><a href="https://www.cnblogs.com/echo3621/OtherPosts.html" title="我评论过的随笔列表">我的参与</a></li><li><a href="https://www.cnblogs.com/echo3621/RecentComments.html" title="我的博客的评论列表">最新评论</a></li><li><a href="https://www.cnblogs.com/echo3621/tag/" title="我的博客的标签列表">我的标签</a></li>
</ul>
<div id="itemListLin_con" style="display:none;">
<ul>

</ul>
</div>
</div></div><div id="sidebar_toptags" class="sidebar-block">
<div class="catListTag">
<h3 class="catListTitle">我的标签</h3>
<ul>
<li><a href="https://www.cnblogs.com/echo3621/tag/JS%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">JS设计模式</a>(1)</li><li><a href="https://www.cnblogs.com/echo3621/tag/JS%E5%8E%9F%E5%9E%8B/">JS原型</a>(1)</li><li><a href="https://www.cnblogs.com/echo3621/tag/JS%E5%8E%9F%E5%9E%8B%E9%93%BE/">JS原型链</a>(1)</li>
</ul>
</div></div><div id="sidebar_categories">
<div class="catListPostArchive">
<h3 class="catListTitle">随笔档案</h3>

<ul>

<li><a id="CatList_LinkList_0_Link_0" href="https://www.cnblogs.com/echo3621/archive/2016/06.html">2016年6月 (2)</a> </li>

</ul>

</div>

</div><div id="sidebar_recentcomments" class="sidebar-block"><div id="recent_comments_wrap">
<div class="catListComment">
<h3 class="catListTitle">最新评论</h3>
	<div id="RecentCommentsBlock"><ul>
        <li class="recent_comment_title"><a href="https://www.cnblogs.com/echo3621/p/5551712.html#4007794">1. Re:JS原型+原型链+设计模式</a></li>
        <li class="recent_comment_body">（2）构造函数模式:无需再函数内部重建创建对象，而使用this指代 function Parent(){ var Child = new Object(); ......</li>
        <li class="recent_comment_author">--风雨造就春华秋实</li>
</ul>
</div>
</div>
</div></div><div id="sidebar_topviewedposts" class="sidebar-block"><div id="topview_posts_wrap">
<div class="catListView">
<h3 class="catListTitle">阅读排行榜</h3>
	<div id="TopViewPostsBlock"><ul><li><a href="https://www.cnblogs.com/echo3621/p/5551712.html">1. JS原型+原型链+设计模式(2336)</a></li><li><a href="https://www.cnblogs.com/echo3621/p/5579002.html">2. 算法——冒泡排序(28)</a></li></ul></div>
</div>
</div></div><div id="sidebar_topcommentedposts" class="sidebar-block"><div id="topfeedback_posts_wrap">
<div class="catListFeedback">
<h3 class="catListTitle">评论排行榜</h3>
	<div id="TopFeedbackPostsBlock"><ul><li><a href="https://www.cnblogs.com/echo3621/p/5551712.html">1. JS原型+原型链+设计模式(1)</a></li></ul></div>
</div>
</div></div><div id="sidebar_topdiggedposts" class="sidebar-block"><div id="topdigg_posts_wrap" style="display: none;">
<div class="catListView">
<h3 class="catListTitle">推荐排行榜</h3>
<div id="TopDiggPostsBlock"></div>
</div></div></div></div><script type="text/javascript">loadBlogSideColumn();</script>
			</div>
			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		
<!--done-->
Copyright ©2019 张处羊
	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->



</body></html>